using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace TextSupport
{
	public class TextCaret
	{
		TextFrameView _view;

		bool _caretVisible;

		public TextCaret(TextFrameView view)
		{
			_view = view;
		}

		public void DrawCaret()
		{
			if (!_caretVisible)
			{
				ToggleCaret();
			}
		}

		public void EraseCaret()
		{
			if (_caretVisible)
			{
				ToggleCaret();
			}
		}

		public void ToggleCaret()
		{
			_caretVisible = !_caretVisible;

			_view.Surface.Invalidate(_view.CaretRect);
		}

		public void Draw(Graphics g)
		{
			if (_caretVisible)
				g.FillRectangle(Brushes.Black, _view.CaretRect);
		}
	}
}
